//         https://ac.nowcoder.com/acm/problem/26221



#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> Or(n + 1);

    for (int i = 1; i <= n; i++) cin >> Or[i].first;
    for (int i = 1; i <= n; i++) cin >> Or[i].second;
    sort(Or.begin() + 1, Or.end(), [](const auto& a, const auto& b)
        {
            if (a.second == b.second) return a.first < b.first;
            return a.second > b.second;
        });

    long long ans1 = 0, ans2 = 0;
    for (int i = 1; i <= k; i++)
    {
        ans1 += Or[i].first;
        ans2 += Or[i].second;
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}